﻿using DBUtility;
using gfLibrary;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IYAKASAPortal.Standard
{
    public partial class CALIB_ZB_DATA_LIST_VIEW : System.Web.UI.Page
    {        
        protected void Page_Load(object sender, EventArgs e)
        {
            string strDevName = string.Empty,strDevCalibName = string.Empty,strJCXH = string.Empty,strStartDate,strEndDate;

            if (Request["JCXH"] != null && !string.IsNullOrEmpty(Request["JCXH"]) && Request["DevCalibName"] != null && !string.IsNullOrEmpty(Request["DevCalibName"])
                && Request["DevName"] != null && !string.IsNullOrEmpty(Request["DevName"]))
            {
                strJCXH = Request["JCXH"].ToString();
                strDevCalibName = Request["DevCalibName"].ToString();
                strDevName = Request["DevName"].ToString();
            }

            strStartDate = (new DateTime(DateTime.Now.Year,1,1)).ToString("yyyy-MM-dd");
            strEndDate = DateTime.Now.ToString("yyyy-MM-dd");

            if (IsPostBack == false)
            {
             
            }
            BindDataToRptList(strJCXH, strDevName, strDevCalibName, strStartDate, strEndDate);
           
        }

        private DataTable GetDataTable(string strJCXH,string strDevName,string strDevCalibName,string strStartDate,string strEndDate)
        {
            DbStoredProcedure DBSPHelper = new DbStoredProcedure();

            SqlParameter[] sqlParams = new SqlParameter[]
            {
                new SqlParameter("@lineNum",strJCXH),
                 new SqlParameter("@devName",strDevName),
                new SqlParameter("@devCalibName",strDevCalibName),
                new SqlParameter("@beginDate",strStartDate),
                new SqlParameter("@endDate",strEndDate)

            };

            DataTable dt = new DataTable();
            DBSPHelper.GetProcDataTable(ref dt, "proc_CALIB_DATA_GetZBSJByDate", sqlParams);
            return dt;

        }


        private void BindDataToRptList(string strJCXH, string strDevName, string strDevCalibName, string strStartDate, string strEndDate)
        {
            try
            {
                DataTable dt = GetDataTable(strJCXH, strDevName, strDevCalibName, strStartDate, strEndDate);
                rptList.DataSource = dt;
                rptList.DataBind();
            }
            catch (Exception ex)
            {

            }
        }

        protected void btnBrowse_Click(object sender, EventArgs e)
        {
            string strBDRQ = Request.Form["BDRQ"];
            string strJCXH = Request.Form["JCXH"];
            string strDevCalibName = Request.Form["DevCalibName"];
            string strDevName = Request.Form["DevName"];
            if (strJCXH == null || strJCXH.Length == 0 || strDevCalibName == null || strDevCalibName.Length == 0 || strDevName == null || strDevName == string.Empty)
            {
                gfAjaxJs.SetAlertMsg(this.UpdatePanel1, "请选择一条记录！");
                return;
            }
            gfLibrary.gfAjaxJs.OpenNewUrl(this.UpdatePanel1, string.Format("PrintZBSJ.aspx?JCXH={0}&DevCalibName={1}&BDRQ={2}&DevName={3}", strJCXH, strDevCalibName, strBDRQ, strDevName));
        }

   


    }
}